package com.app.common.download

class Downloader {
    private var delegate: DownloaderDelegate = EmptyDelegate()

    var count = delegate.workCount

    fun updateCount() {
        count = delegate.updateWorkCount()
    }

    fun setDelegate(delegate: DownloaderDelegate) {
        this.delegate.release()
        this.delegate = delegate
    }

    fun addEvent(event: Event) {
        delegate.addEvent(event)
    }

    fun removeEvent(event: Event) {
        delegate.removeEvent(event)
    }

    fun add(path: String, fileName: String) {
        delegate.addWork(path, fileName)
    }

    fun remove(path: String) {
        delegate.cancelWork(path)
    }

    fun remove() {
        delegate.cancelAll()
    }

    fun release() {
        delegate.release()
    }
}